<?php
App::import('Sanitize');
class BuyhistoriesController extends AppController {
	var $name = 'Buyhistories';
	var $uses = array('Buyhistory', 'Product', 'User');
	var $helpers = array('Html', 'Session','Thumb');
	var $components = array('Auth','Seo');
	var $paginate = array(
		'limit' => 10,
		'order' => array('Buyhistory.created' => 'desc')
	);

	function beforeFilter() {
		parent::beforeFilter();
	}
	function beforeRender() {
		parent::beforeRender();
	}

	function admin_index(){
		$user=$this->Auth->user();
		if(!$user||$user['User']['role']!=ADMIN){
			$this->redirect(array('controller'=>'users','action'=>'admin_login'));
		}
		$sales = $this->paginate();
		$all_users = $this->User->find('list');
		$this->set('sales',$sales);
		$this->set('all_users',$all_users);
		if(!empty($sales))
			$this->set('dataempty',false);
		else
			$this->set('dataempty',true);
	}
}
?>
